import FileSaver from 'file-saver'

// 入参options，文件名，后缀，接口名字，默认xlsx，支持任意格式文件
export default {
  async download(options = { fileName: 'template', end: '.xlsx', api: 'download', data: {} }) {
    const binary = await window.$apis[options.api](options.data)
    FileSaver.saveAs(new Blob([binary], { type: 'application/octet-stream' }), `${options.fileName}${options.end}`)
  }
}
